'use strict';

const Controller = require('egg').Controller;

class LeaveController extends Controller {
  async addLeave () {
    const { ctx, service } = this
    const payload = ctx.request.body || {}
    // console.log('payload', payload)
    const res = await service.leave.addLeave(payload)
    ctx.body = res
  }

  async updateLeave () {
    const { ctx, service } = this
    const payload = ctx.request.body || {}
    // console.log('payload', payload)
    const res = await service.leave.updateLeave(payload)
    ctx.body = res
  }

  async getLeave () {
    const { ctx, service } = this
    const params = ctx.query
    // console.log('params', params)
    const res = await service.leave.getLeave(params)
    ctx.body = res
  }

  async getLeavemohu () {
    const { ctx, service } = this
    const params = ctx.query
    // console.log('params', params)
    const res = await service.leave.getLeavemohu(params)
    ctx.body = res
  }

  // 删除
  async deleteLeave () {
    const { ctx, service } = this
    const payload = ctx.request.body || {}
    // console.log('payload', payload)
    const res = await service.leave.deleteLeave(payload)
    this.ctx.body = res
  }
}

module.exports = LeaveController;
